package com.aw.baselib.util

import android.content.Context
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import com.aw.baselib.util.AwLog.d

/**
 * @author : hzw
 * @date : 2020/6/2
 */
object AwManifestUtil {
    /**
     * 获取注册清单metadata value
     * @param context
     * @param metaDataName
     * @return
     */
    fun getMetaDataValue(context: Context, metaDataName: String?): String? {
        val pm = context.packageManager
        val appinfo: ApplicationInfo
        var metaDataValue = "defaultvalue"
        try {
            appinfo = pm.getApplicationInfo(context.packageName, PackageManager.GET_META_DATA)
            val metaData = appinfo.metaData
            metaDataValue = metaData.getString(metaDataName).toString()
            return metaDataValue
        } catch (e: Exception) {
            e.printStackTrace()
        }
        d("getMetaDataValue result: $metaDataValue")
        return metaDataValue
    }
}